package com.thinkTank.oa.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.thinkTank.oa.entity.Dictiontry;
import com.thinkTank.oa.util.Json;

/**
 * 用于地区的三级联动
 * 
 * @author pdz
 * @date 2018年8月15日
 */
@Controller
@RequestMapping(value = "/area")
public class AreaController extends BaseController {

    // 根据省份id获取城市数据后直接使用@ResponseBody装成json数据
    @RequestMapping("/getCityByProvinceId/{id}")
    @ResponseBody
    public Json getCityByProvinceId(@PathVariable("id") String id) {
        List<Dictiontry> cityList = getCityByProvince(id);
        if (cityList != null) {
            return new Json(true, "success", cityList);
        } else {
            return new Json(false, "fail", null);
        }
    }

    // 根据城市id获取区域数据后直接使用@ResponseBody装成json数据
    @RequestMapping("/getAreaByCityId/{id}")
    @ResponseBody
    public Json getAreaByCityId(@PathVariable("id") String id) {
        List<Dictiontry> areaList = getAreaByCity(id);
        if (areaList != null) {
            return new Json(true, "success", areaList);
        } else {
            return new Json(false, "fail", null);
        }
    }

}
